/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.tms.module.demandextrainfo.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.tms.global.exception.CommonException;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.time.LocalDateTime;

/**
 * 需求单补充信息实体类
 *
 * @author Blade
 * @since 2022-03-08
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Validated
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "TmDemandExtraInfo对象", description = "需求单补充信息")
public class TmDemandExtraInfo extends TenantEntity {

	private static final long serialVersionUID = 1L;

	/**
	 * 主键
	 */
	@Null(groups = FILL_INFO.class, message = "主键不传")
	@ApiModelProperty(value = "主键")
	private Long id;
	/**
	 * 装货日期
	 */
	@ApiModelProperty(value = "装货日期")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private LocalDateTime loadDate;
	/**
	 * 开船日期
	 */
	@ApiModelProperty(value = "开船日期")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private LocalDateTime departureDate;
	/**
	 * 需求单ID
	 */
	@NotNull(groups = FILL_INFO.class, message = "关联ID必传")
	@ApiModelProperty(value = "关联ID")
	private Long parentId;
	/**
	 * 提单号
	 */
	@ApiModelProperty(value = "提单号")
	private String deliverNo;
	/**
	 * 发运港
	 */
	@ApiModelProperty(value = "发运港")
	private String sendLocation;
	/**
	 * 目的港
	 */
	@ApiModelProperty(value = "目的港")
	private String targetLocation;
	/**
	 * 发运港
	 */
	@TableField(exist = false)
	@ApiModelProperty(value = "发运港")
	private String sendLocationTxt;
	/**
	 * 目的港
	 */
	@TableField(exist = false)
	@ApiModelProperty(value = "目的港")
	private String targetLocationTxt;
	/**
	 * 箱量
	 */
	@ApiModelProperty(value = "箱量")
	private String boxCapacity;
	/**
	 * 实际装货日期
	 */
	@ApiModelProperty(value = "实际装货日期")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private LocalDateTime reallyLoadData;
	/**
	 * 车皮号
	 */
	@ApiModelProperty(value = "车皮号")
	private String trainShell;
	/**
	 * 发站
	 */
	@ApiModelProperty(value = "发站")
	private String trainSendLocation;
	/**
	 * 到站
	 */
	@ApiModelProperty(value = "到站")
	private String trainTargetLocation;
	/**
	 * 发站
	 */
	@TableField(exist = false)
	@ApiModelProperty(value = "发站")
	private String trainSendLocationTxt;
	/**
	 * 到站
	 */
	@TableField(exist = false)
	@ApiModelProperty(value = "到站")
	private String trainTargetLocationTxt;
	/**
	 * 铁路批车次
	 */
	@ApiModelProperty(value = "铁路批车次")
	private String trainBatchNum;
	/**
	 * 船舶
	 */
	@ApiModelProperty(value = "船舶")
	private String boat;
	/**
	 * 罐箱号
	 */
	@ApiModelProperty(value = "罐箱号")
	private String containerNo;

	/**
	 * 单据类型
	 */
	@ApiModelProperty(value = "单据类型")
	private String orderType;

	/**
	 * 运输类型
	 */
	@ApiModelProperty(value = "运输类型")
	private String transportType;


	/***
	 * 根据情况返回MP的wrapper
	 * @param type
	 * @param entity
	 * @return
	 */
	public static LambdaQueryWrapper<TmDemandExtraInfo> buildWrapper(Integer type, TmDemandExtraInfo entity) {
		LambdaQueryWrapper<TmDemandExtraInfo> result = new LambdaQueryWrapper<>();
		switch (type) {
			case 1:
				//仅设置 eq 订单号ID
				result = result.eq(TmDemandExtraInfo::getParentId, entity.getParentId());
				break;
			default:
				CommonException.throwCommonException("错误类型");
		}
		return result;
	}


	/**
	 * 补全信息校验
	 */
	public interface FILL_INFO {
	}


	/**
	 * 运输单补全信息校验
	 */
	public interface FILL_INFO_Transport {
	}

}
